<?php

/* @var $this \yii\web\View */
/* @var $content string */

use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use common\widgets\Alert;
use yii\widgets\Breadcrumbs;
use yii\helpers\Url;
//use yii\bootstrap\Alert;
use webvimark\modules\UserManagement\components\GhostMenu;
use webvimark\modules\UserManagement\components\GhostNav;
use webvimark\modules\UserManagement\UserManagementModule;

AppAsset::register($this);
//引入css
//$this->registerCssFile('@web/js/list/bootstrap-3.3.7-dist/css/bootstrap.min.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);

$this->registerCssFile('@web/css/layui/css/layui.css', ['position' => $this::POS_HEAD]);

$this->registerCssFile('@web/css/common/header-footer.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/common/defaultPage.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);


//引入js
//$this->registerJsFile('@web/js/list/jquery/jquery.form.js',['depends'=>['backend\assets\AppAsset'],'position'=>$this::POS_HEAD]);
$this->registerJsFile('@web/js/common.js', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerJsFile('@web/css/layui/layui.all.js', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCss('  
    .dropdown-menu > .active > a{background : #fff; color:#777;}  
');


?>
<style type="text/css">
    /*.table  {
        margin-top: 6px;
    }
    .grid-view {
        position: relative;
        padding-bottom: 30px;
    }
    .summary {
        margin-top: 23px;
    }
    .pagination {
        position: absolute;
        left: 50%;
        width: 100%
    }
    .form-inline {
        margin-top: 10px;
    }*/
</style>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--//视口快捷键:meta:vp+tap键 (可视区宽度为当前屏幕宽度,自适应手机宽度,禁止手机缩放,禁止用户放大或缩小到实际尺寸之上)-->
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0,user-scalable=no,maximum-scale=1.0,minimum-scale=1.0"/>
    <!--    <meta name="viewport" content="width=device-width, initial-scale=1">-->
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>

    <!--当遇到IE9以下的版本的使用会执行下面注释的代码  (HThtml5shiv.min.js和respond.js IE8支持HTML5元素和媒体查	询,respond.min.js在只能在服务器上运行,在本地不会运行-->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body>
<?php $this->beginBody() ?>

<!--//头部-->
<div class="header">
    <div class="container">
        <div class="row">
            <div class="left col-xs col-sm-6  col-md-6 col-lg-6 ">
                <a href="/"><?= Html::img('@web/image/common/pm5log.png', ['alt' => 'Responsive image', 'class' => 'img-responsive']) ?></a>
            </div>
            <div class="right col-xs col-sm-6  col-md-6 col-lg-6">
                <div class="row">
                    <div class="col-sm-8 col-md-8 col-lg-8">
                        <p class="pull-right"></p>
                    </div>
                    <div class="col-sm-4 col-md-4 col-lg-4">

                            <span class="user">
                                <?php
                                $cookie = \Yii::$app->request->cookies;
                                if (!empty($cookie['userheader'])) {
                                    $avatar = $cookie['userheader'];
                                    echo <<<IMG
<img src="$avatar" class="pull-left" style="width:40px;border-radius:25px;margin-top:4px;margin-left:3px;">
IMG;
                                } else {
                                    echo <<<IMG
<img src="/image/officeHall/person.png" style="width:40px;border-radius:25px;margin-top:4px;margin-left:3px;" class="pull-left">
IMG;
                                }
                                ?>
                                <ul style="display: none;">
                                    <!-- <li><a href="<?= Url::toRoute('/instation-message/index'); ?>">我的提醒</a></li> -->
                                    <li><a href="<?= Url::toRoute('/user/change-own-password'); ?>">修改密码</a></li>
                                    <li><a href="<?= Url::toRoute('/auth/logout'); ?>">退出登录</a></li>
                                </ul>
                            </span>

                        <span class=" exit glyphicon " aria-hidden="true">
                        <!-- <?= Html::a('退出', ['/user-management/auth/logout'], [
                            'data' => [
                                'method' => 'post'
                            ]
                        ]) ?> -->

                            <a href="<?= Url::toRoute('/instation-message/index'); ?>">我的提醒</a>
                            <span class="remind"></span>

                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--//导航区-->
<div class="nav nav-fix">
    <div class="container">
        <div class="row">
            <?php

            NavBar::begin([
                'brandUrl' => Yii::$app->homeUrl,
                'options' => [
                    'class' => 'fix',//navbar-fixed-top
                ],
                'renderInnerContainer' => true,
            ]);

            if (Yii::$app->user->identity->superadmin) {
                echo Nav::widget([
                    'options' => ['class' => 'nav  navbar-nav col-sm-12 col-md-12  nav-self'],
                    'items' => [
                        [
                            'label' => '办公大厅',
                            'options' => ['class' => 'dropdown'],
                            'items' => [
                                ['label' => '办公大厅', 'url' => '/site/index'],
                                ['label' => '我的提醒', 'url' => ['/instation-message/index']],
                                ['label' => '智能阅卷', 'url' => ['/yue-juan/index']],
                            ]
                        ],
                        [
                            'label' => '资产管理',
                            'options' => ['class' => 'dropdown', 'role' => 'presentation'],
                            'items' => [
                                ['label' => '资产包管理', 'url' => ['/search-package/search']],
                                ['label' => '我的资产包', 'url' => ['/my-package/get-my-package']],
                                ['label' => '项目管理', 'url' => ['/project']],
                                ['label' => '我的项目', 'url' => ['/my-project/my-involvement']],
                            ]
                        ],
                        [
                            'label' => '客户管理',
                            'url' => ['/customer/index'],
                        ],
                        [
                            'label' => '审批管理',
                            'options' => ['class' => 'dropdown1'],
                            'url' => ['/audit-management/my-application']
                        ],
                        [
                            'label' => '资源中心',
                            'options' => ['class' => 'dropdown', 'role' => 'presentation'],
                            'items' => [
                                ['label' => '资产包库', 'url' => ['/package-ease/index']],
                                ['label' => '债权项目库', 'url' => ['/project-ease/index']],
                                ['label' => '特殊项目库', 'url' => ['/project-single/index']],
                                ['label' => '外部平台链接库', 'url' => ['/link/index']],
                            ]
                        ],
                        [
                            'label' => '档案管理',
                            'options' => ['class' => ''],
                            'items' => [
                                ['label' => '开发中...', 'url' => ['/']],

                            ]
                        ],
                        [
                            'label' => '后台管理',
                            'options' => ['class' => 'dropdown'],
                            'items' => [
                                ['label' => '管理员管理', 'url' => ['/user/index']],
                                ['label' => '权限组管理', 'url' => ['/user-management/auth-item-group/index']],
                                ['label' => '角色管理', 'url' => ['/user-management/role/index']],
                                ['label' => '权限管理', 'url' => ['/user-management/permission/index']],
                                ['label' => '部门管理', 'url' => ['/user-department/index']],
                                ['label' => '岗位管理', 'url' => ['/user-post/index']],
                                ['label' => '日志查看', 'url' => ['/user-management/user-visit-log/index']],
                            ]
                        ]
                    ],
                    //'submenuTemplate' => "\n<ul class='dropdown-menu'>\n{items}\n</ul>\n",
                ]);
            } else {
                echo GhostNav::widget([
                    'options' => ['class' => 'nav  navbar-nav col-sm-12 col-md-12  nav-self'],
                    'items' => [
                        [
                            'label' => '办公大厅',
                            'options' => ['class' => 'dropdown'],
                            'items' => [
                                ['label' => '办公大厅', 'url' => '/site/index'],
                                ['label' => '我的提醒', 'url' => ['/instation-message/index']],
                                ['label' => '智能阅卷', 'url' => ['/yue-juan/index']],
                            ]
                        ],
                        [
                            'label' => '资产管理',
                            'options' => ['class' => 'dropdown', 'role' => 'presentation'],
                            'items' => [

                                ['label' => '资产包管理', 'url' => ['/search-package/search']],
                                ['label' => '我的资产包', 'url' => ['/my-package/get-my-package']],
                                ['label' => '项目管理 ', 'url' => ['/project/index']],
                                ['label' => '我的项目', 'url' => ['/my-project/my-involvement']],
                            ]
                        ],
                        [
                            'label' => '客户管理',
                            'url' => ['/customer/index'],
                        ],
                        [
                            'label' => '审批管理',
                            'options' => ['class' => 'dropdown1'],
                            'url' => ['/audit-management/my-application']
                        ],
                        [
                            'label' => '资源中心',
                            'options' => ['class' => 'dropdown', 'role' => 'presentation'],
                            'items' => [
                                ['label' => '资产包库', 'url' => ['/package-ease/index']],
                                ['label' => '债权项目库', 'url' => ['/project-ease/index']],
                                ['label' => '特殊项目库', 'url' => ['/project-single/index']],
                                ['label' => '外部平台链接库', 'url' => ['/link/index']],
                            ]
                        ],
//                        [
//                            'label' => '档案管理',
//                            'options' => ['class' => ''],
//                            'items' => [
//                                ['label' => '开发中...', 'url' => ['/']],
//
//                            ]
//                        ]
                    ],
                ]);
            }


            NavBar::end();

            ?>
        </div>
    </div>
</div>
<!-- 导航区结束 -->
<div class="wrap">

    <div class="container-fluid">
        <div class="container">
            <?= Breadcrumbs::widget([
                'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
            ]) ?>
            <?= Alert::widget() ?>
            <?= $content ?>
        </div>
    </div>
</div>

<footer class="myfooter">
    <nav class="navbar navbar-default">
        <div class="container">
            <p class="text-center">
                COPYRIGHT &copy;2017 新大唐资产管理集团 ALL RIGHT RESERVED
            </p>
        </div>
    </nav>
</footer>

<?php
$cssString = <<<CSS
.navbar {margin-bottom:0px;}
.panel{border: 0px;}
/*.container-fluid{margin-top:70px;}*/
.breadcrumb{background-color:#fff; box-shadow: 0px 1px 6px 0px rgba(91, 91, 91, 0.18);border-radius:0px;}
.lte-hide-title {font-size:30px;margin-top:20px;margin-bottom: 10px;font-weight:500;line-height: 1.1;}
.panel-default{box-shadow:0px 1px 6px 0px rgba(91, 91, 91, 0.18);background: #fff;border-radius:0px;}
.nav .active .active a{height:auto;}
.panel-body .row {padding: 5px 0px;}
.wrap {margin-top: 30px;}

.navbar{
        border: none!important;
    }
CSS;
$this->registerCss($cssString, ['position' => $this::POS_END]);
?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>


<script type="text/javascript">
    ajaxGetMessageNum();
    function ajaxGetMessageNum() {
        $url = '/instation-message/index';
        $data = [];
        $(".remind").hide();
        $.get($url, $data, function (res) {
            if (res > 0) {
                $(".remind").show();
                $(".remind").text(res)
            } else {
                $(".remind").hide()
            }
        })
    }

    //判断用户无操作系统自动退出
    function SetCookie(name, value) {
        var exp = new Date();
        exp.setTime(exp.getTime() + 3 * 24 * 60 * 60 * 1000); //3天过期
        document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + exp.toGMTString() + ";path=/";
        return true;
    }
    ;
    function get_cookie(c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=")
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1
                c_end = document.cookie.indexOf(";", c_start)
                if (c_end == -1) c_end = document.cookie.length
                return unescape(document.cookie.substring(c_start, c_end))
            }
        }
        return ""
    }
    //    var count_unlock = 0;
    SetCookie('count_unlock', 0);
    var outTime_unlock = 300;//300分钟
    window.setInterval(go_unlock, 1000);
    function go_unlock() {
//        count_unlock++;
        SetCookie('count_unlock', (Number(get_cookie('count_unlock')) + 1));
//        console.log(get_cookie('count_unlock'));
        if (get_cookie('count_unlock') == outTime_unlock * 60) {
//            alert("您因长时间未进行操作导致页面过期");
            window.location.href = '/index.php/auth/logout';
        }
    }
    var x_unlock;
    var y_unlock;
    //监听鼠标
    document.onmousemove = function (event) {
        var x1 = event.clientX;
        var y1 = event.clientY;
        if (x_unlock != x1 || y_unlock != y1) {
//           count_unlock = 0;
            SetCookie('count_unlock', 0);
        }

        x_unlock = x1;
        y_unlock = y1;
    };
    //监听键盘
    document.onkeydown = function () {
//        count_unlock = 0;
        SetCookie('count_unlock', 0);
    };
</script>
